babl-space: add comments, do not use a static temp struct
authorØyvind Kolås <pippin@gimp.org>
Wed, 11 Jul 2018 19:11:17 +0000 (21:11 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 11 Jul 2018 19:11:17 +0000 (21:11 +0200)
babl/babl-space.c

index 6e8774d27e0c4047ac95b0ae2a1e0481391042b5..793ab7f92b83a34b67ce5ec3340362c078614a79 100644 (file)
@@ -230,9 +230,12 @@ babl_space_from_rgbxyz_matrix (const char *name,
                                const Babl *trc_blue)
 {
   int i=0;
-  static BablSpace space;
+  BablSpace space;
   space.instance.class_type = BABL_SPACE;
   space.instance.id         = 0;
+  /* it would be better to reconstruct chromaticities - since they
+   * can be asked for with API
+   */
   space.xr = rx;
   space.yr = gx;
   space.xg = bx;
@@ -243,6 +246,7 @@ babl_space_from_rgbxyz_matrix (const char *name,
   space.yw = gz;
   space.pad = bz;
 
+
   space.whitepoint[0] = wx;
   space.whitepoint[1] = wy;
   space.whitepoint[2] = wz;
@@ -267,7 +271,9 @@ babl_space_from_rgbxyz_matrix (const char *name,
     return NULL;
   }
   /* transplant matrixes */
-  //babl_space_compute_matrices (&space_db[i]);
+
+  /* XXX: there is a potential race condition if making the same space in
+          multiple threads */
   space.RGBtoXYZ[0] = rx;
   space.RGBtoXYZ[1] = gx;
   space.RGBtoXYZ[2] = bx;
@@ -295,7 +301,6 @@ babl_space_from_rgbxyz_matrix (const char *name,
              babl_get_name (space.trc[0]),
              babl_get_name(space.trc[1]), babl_get_name(space.trc[2]));
 
-
   return (Babl*)&space_db[i];
 }